package com.ruoyi.h5.controller;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.system.domain.MiniSubject;
import com.ruoyi.system.domain.dto.AuthorizeDTO;
import com.ruoyi.system.domain.vo.h5.MainSubjectVO;
import com.ruoyi.system.domain.vo.h5.SearchVO;
import com.ruoyi.system.service.MiniUserService;
import com.ruoyi.system.service.h5.IHomeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 主页相关
 * @author :liding
 * @date : 2023/8/2 17:20
 */
@RestController
@RequestMapping("/app")
@Slf4j
@Anonymous
public class HomeController extends BaseController {

    @Autowired
    private IHomeService homeService;

    /**
     * 微信授权接口以及用户信息查询
     * @param params
     * @return
     */
    @PostMapping("/wx/authorize")
    public AjaxResult authorize(@RequestBody AuthorizeDTO params){
        return homeService.authorize(params);

    }

    /**
     * 热点数据
     * @return
     * @response com.ruoyi.common.core.domain.AjaxResult<java.util.List<com.ruoyi.system.domain.MiniSubject>>
     */
    @GetMapping("hot")
    public AjaxResult<List<MiniSubject>> hot(){
        return homeService.hot();
    }
    /**
     * 热点数据下面的沸与热
     * @return
     * @response com.ruoyi.common.core.domain.AjaxResult<java.util.List<com.ruoyi.system.domain.MiniSubject>>
     */
    @GetMapping("hot2")
    public AjaxResult<List<MiniSubject>> hot2(){
        return homeService.hot2();
    }

    /**
     * 主页搜索接口
     * @param name
     * @return
     */
    @GetMapping("search")
    public AjaxResult<SearchVO> search(String name){
        return homeService.search(name);
    }
    /**
     * 主线题材
     * @return
     */
    @GetMapping("mainSubject")
    public AjaxResult<List<MainSubjectVO>> mainSubject(){
        return homeService.mainSubject();
    }
}
